package ui;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

import data.Connect;
import data.Activity;

public class UserDashboard extends JPanel {
	
	
//	for(User user : connect.getUsers(1)){	
//	data = data + ,"user.getID()+" "+user.getFirstName()+" "+user.getLastName());
//	}
	
//	for(User user : connect.getUsers(1)){	
//	
//	System.out.println(user.getID()+" "+user.getFirstName()+" "+user.getLastName());
//	
//	
//}


	public UserDashboard() {
		
		setBackground(Color.decode("#FFFFFF"));
		setLayout(null);
		
	    ImageIcon adminPanelGradient = new ImageIcon("gfx/adminPanelGradient.png");

		JLabel topPanel = new JLabel(adminPanelGradient);	
		topPanel.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.decode("#CCCCCC")));
		topPanel.setBounds(0, 0, 650, 80);
		
		JLabel panelTitle = new JLabel("Welcome User");
		panelTitle.setBounds(10, 35, 650, 50);
		panelTitle.setFont(new Font("Helvetica Neue", Font.PLAIN, 28));
		
		JLabel activityLabel = new JLabel("Recent Activities");
		activityLabel.setBounds(10,100,630,20);
				
		
		    DefaultTableModel activityModel = new DefaultTableModel();
		    JTable activityTable = new JTable(activityModel);
	
		    activityModel.addColumn("Description");
		    activityModel.addColumn("Date");
		    activityModel.addColumn("Amount");
		    activityModel.addColumn("Amount (DKK)");
		    activityModel.addColumn("Type");
	
		    // LOOPING THROUGH OUR ARRAY TO CREATE ROWS		    
			Connect connect = new Connect();
			for(Activity activity : connect.getActivities()){
				activityModel.insertRow(0, new Object[] {
						activity.getActivityDescription(), 
						activity.getActivityDate(), 
						activity.getActivityAmount(), 
						activity.getActivityAmountDKK(),
						activity.getActivityType()
						});
			}
		    JScrollPane scroll = new JScrollPane(activityTable);
			scroll.setBounds(10,120,630,100);
		
		// ADDING ELEMENTS
		add(panelTitle);
		add(topPanel);
		add(activityLabel);
	    add(scroll);

	    
	
		// ADDING ELEMENTS TO logoutPanel

	}
	public void addACList(ActionListener ac){
		
		
	}

}
